// cf-220c
// run: $exec < input
#include <iostream>
#include <set>

int const maxn = 100007;
int a[maxn], b[maxn];
int posa[maxn], posb[maxn];
int n;

std::multiset<int> msl;
std::multiset<int> msr;
int dl, dr;  // delta for left part and right part

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n;
	for (int i = 1; i <= n; i++) {
		std::cin >> a[i];
		posa[a[i]] = i;
	}
	for (int i = 1; i <= n; i++) {
		std::cin >> b[i];
		posb[b[i]] = i;
	}

	for (int i = 1; i <= n; i++)
		msl.insert(i - posb[a[i]]);

	for (int i = 1; i <= n; i++) {
		int ans = 1 << 30;
		auto it = msl.lower_bound(-dl);
		if (it != msl.end()) ans = std::min(ans, *it + dl);
		if (it != msl.begin()) ans = std::min(ans, -*std::prev(it) - dl);
		it = msr.lower_bound(-dr);
		if (it != msr.end()) ans = std::min(ans, *it + dr);
		if (it != msr.begin()) ans = std::min(ans, -*std::prev(it) - dr);
		std::cout << ans << '\n';

		int rl = posa[b[i]] - i;
		msl.erase(msl.find(rl));
		dl++; dr--;
		msr.insert(n - posa[b[i]] - dr);
		while (msr.find(-1 - dr) != msr.end()) {
			msr.erase(msr.find(-1 - dr));
			msl.insert(1 - dl);
		}
	}
}

